package leetcode.editor.cn.q1xx

import leetcode.editor.cn.ListNode

class Q141 {
    fun hasCycle(head: ListNode?): Boolean {
        if (head==null) return false
        var fast = head.next
        var slow = head
        while (slow != fast) {
            if (fast?.next == null) {
                return false
            }
            slow = slow?.next
            fast = fast.next?.next
        }
        return true
    }
}